package Code.CodeBlock;
//构造代码块
public class Structure {
    private String name;
    private int age;

    {
        //写在成员位置的代码块叫做构造代码块
        //可以把多个构造方法中的重复代码抽取出来
        //在创建本类对象的时候会先执行代码块里面的内容
       // System.out.println("开始创建对象");
    }

    public Structure() {
        System.out.println("空参构造");
        System.out.println();
    }

    public Structure(String name, int age) {
        System.out.println("有参构造");
        this.name = name;
        this.age = age;
    }

    public Structure(String name) {
        System.out.println("一个参数的构造");
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
